﻿@{
    Layout = null;
    Model.Intelligence_AutoResend autoResendData = ViewBag.AutoResend;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>管理工具</title>
    <!--SEO优化部分 & 全局样式部分-->
    @Html.Partial("_Title")
    <script src="~/Theme/layui/layui.js"></script>
    <script src="~/Theme/layer/layer.js"></script>
    <link href="~/Theme/css/IntelligenceManageCSS.css" rel="stylesheet" />
</head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <!--头部-->
        @Html.Partial("_Top")

        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <li class="layui-nav-item layui-this"><a href="/IntelligenceManage/AutoResend">自动重发商品</a></li>
                    <li class="layui-nav-item"><a href="/IntelligenceManage/AutoAppraise">自动评价订单</a></li>
                    <li class="layui-nav-item"><a href="/IntelligenceManage/AutoWindow">自动橱窗位</a></li>
                    <li class="layui-nav-item"><a href="/IntelligenceManage/AutoStock">自动补库存</a></li>                  
                </ul>
            </div>
        </div>

        <div class="layui-body" style="">
            <fieldset class="layui-elem-field layui-field-title mt20">
                <legend>自动重发设置</legend>
            </fieldset>

            <div class="layui-row">
                <div class="layui-form" >
                    <div class="layui-form-item">
                        <label class="layui-form-label">重发开关</label>
                        <div class="layui-input-block">
                            @if (autoResendData.IsResend)
                            {
                                <input type="checkbox" name="open" checked="" lay-skin="switch" lay-text="开启|关闭">
                            }
                            else
                            {
                                <input type="checkbox" name="open" lay-skin="switch" lay-text="开启|关闭">
                            }                   
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">重发日志</label>
                        <div class="layui-input-block">
                            <span>今日已重发：<a><span class="layui-badge">@ViewBag.TodayLog</span>个</a></span>，
                            <span>共重发：<a><span class="layui-badge">@ViewBag.Atotalof</span>个</a></span>
                        </div>
                    </div>

                    <div class="layui-form-item" pane="">
                        <label class="layui-form-label">重发范围</label>
                        <div class="layui-input-block">
                            @if (autoResendData.IsAllProduct)
                            {
                                <input type="checkbox" name="ResendRange-AllPro" lay-skin="primary" title="按全店产品重发" value="AllPro" checked="">
                            }
                            else
                            {
                                <input type="checkbox" name="ResendRange-AllPro" lay-skin="primary" title="按全店产品重发" value="AllPro">
                            }

                            @if (autoResendData.IszidingyiProduct)
                            {
                                <input type="checkbox" name="ResendRange-customResend" lay-skin="primary" title="按自定义商品重发" value="customResend" checked="">
                            }
                            else
                            {
                                <input type="checkbox" name="ResendRange-customResend" lay-skin="primary" title="按自定义商品重发" value="customResend">
                            }

                        </div>
                    </div>

                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">注意事项</label>
                        <div class="layui-input-block mt20 border-p1-c1">
                            <ul class="ih30 f12">
                                <li><span class="layui-badge-dot"></span>1.凡开启自动重发的店铺，系统会尽可能保证你店铺的商品处于上架状态</li>
                                <li><span class="layui-badge-dot"></span>2.请经常登录系统避免因授权过期。</li>
                                <li><span class="layui-badge-dot"></span>2.如使用过程中遇到任何问题，请及时与软件开发者联系。</li>
                            </ul>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn  submitbtn">保存设置</button>
                        </div>
                    </div>
                </div>
            </div>

            <input type="hidden" value="@autoResendData.MemberId" id="MemberId" />
            <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
            <script>


                layui.use(['form', 'layedit', 'laydate'], function () {
                   
                  
                    //监听指定开关
                    //form.on('switch(switchTest)', function (data) {
                    //    layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                    //        offset: '60px'
                    //    });
                    //    layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
                    //});

                    // 点击保存。
                    $(".submitbtn").click(function () {

                        var MemberId = $("#MemberId").val();
                        var open = $("input[name='open']").prop('checked')
                        var AllPro = $("input[name='ResendRange-AllPro']").prop('checked')
                        var customResend = $("input[name='ResendRange-customResend']").prop('checked')


                        var data = JSON.stringify({ MemberId: MemberId, open: open, AllPro: AllPro, customResend: customResend });

                        //提示弹层
                        layer.msg('正在提交保存...', { icon: 16, shade: [0.5, '＃f5f5f5'], scrollbar: false, offset: '300px', time: 50000 });
                        $.ajax({
                            url: "/api/IntelligenceManageAPI/UpdateAutoResend",
                            type: "Post",
                            dataType: "json",
                            data: { data: data },
                            success: function (data) {

                                //关闭弹层提示
                                layer.closeAll();

                                if (data == true) {
                                    layer.msg('保存成功', {
                                        offset: '60px'
                                    });
                                }
                                else {

                                    layer.msg('保存失败', {
                                        offset: '60px'
                                    });

                                }


                               
                            }
                        })

                    })                
                });
            </script>


        </div>

        <!--底部-->
        @*@Html.Partial("_Foot")*@
    </div>
</body>
</html>



